package cn.cloud.butler.uploadapi.repository;

import cn.cloud.butler.uploadapi.domain.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface MacAlarmRepository extends JpaRepository<MacAlarmEntity,Integer> {
    //通过compid查询机床信息
    @Query(value=" SELECT * FROM MacAlarm WHERE UploadTime = ?1 and MacSN = ?2 and AlarmID = ?3" ,nativeQuery = true)
    MacAlarmEntity selectByTimeAndMacsnAndAlarmId(String uploadTime,String macSn,int alarmId);

    @Query(value=" SELECT MAX(ID) FROM MacAlarm WHERE  MacSN = ?1 and AlarmID = ?2 " ,nativeQuery = true)
    int selMaxAlarmByMacsnAlarmid(String macSn,int alarmId);


    @Modifying
    @Query(value = "UPDATE MacAlarm SET ReleaseTime = ?2 WHERE ID = ?1" ,nativeQuery = true)
    void updateReleaseById(int id, String releaseTime);


}
